﻿
/*

    $('.tab-mode2').mstab({
        "event":"click mouseenter",
        "hd":".tab-hd",
        "cont":".tab-cont .contDate"
    });

*/

    //updata
	$.fn.mstab = function(op){
		var de = {
			"action_class":"cur",
			"event":"click mouseenter",
			"hd":".tab-hd",
			"cont":".tab-cont .contDate"
		};

		function tab(_this) {
			var _op = $.extend(de,op);
			var _hd = _this.find(_op.hd);
			var contBody = _this.find(_op.cont);
			var $link_a = _this.find('.more-link');
			_this.find(_op.hd).on(_op.event, 'a', function () {
				var $this = $(this),
					index = $this.index() || $this.parent().index(),
					_href = $this.attr('data-href');
				if(_href){$link_a.attr('href',_href)}

				if(typeof contBody.eq(index)[0] === 'undefined'){return}

				_hd.find('.' + _op.action_class).removeClass(_op.action_class);
				$this.addClass(_op.action_class);
				contBody.hide();
				contBody.eq(index).show();
				console.log(index);
				console.log('contBody.eq(index):',contBody.eq(index)[0]);
			});
		}

		this.each(function () {
			var _this = $(this);
			tab(_this);
		});
	};